<template>
    <div class="cartcontrol" >
        <transition name="move">
            <!-- 当count为0时 转为布尔值为false 减号按钮不显示 count数字也不显示 -->
            <div class="iconfont icon-remove_circle_outline" v-if="food.count" @click.stop="updateFoodCount(!isAdd)"></div>
        </transition>
        <div class="cart-count" v-if="food.count">{{food.count}}</div>
        <div class="iconfont icon-add_circle" @click.stop="updateFoodCount(isAdd)"></div>
    </div>
</template>
<script>
export default {
    props: {
        food:{
            type:Object,
        }
    },
    data() {
        return {
            isAdd:true
        };
    },
    computed: {

    },
    mounted() {

    },
    methods: {
        updateFoodCount(isFlag) {
            // console.log(this.food);
            let {food} = this
            console.log(food);
            
            this.$store.dispatch('updateFoodCount',{food,isFlag})
           
        }
    },
    components: {

    },
};
</script>

<style scoped lang='stylus' >
@import "../../common/stylus/mixins.styl"

  .cartcontrol
    font-size: 0
    .cart-decrease
      display: inline-block
      padding: 6px
      line-height: 24px
      font-size: 24px
      color: rgb(0, 160, 220)

    .icon-remove_circle_outline
      display: inline-block
      padding 6px
      line-height 24px
      font-size 24px
      color $green
      &.move-enter-active, &.move-leave-active
        transition all .3s
      &.move-enter, &.move-leave-to
        opacity 0
        transform translateX(15px) rotate(180deg)
    .cart-count
      display: inline-block
      vertical-align: top
      width: 12px
      padding-top: 6px
      line-height: 24px
      text-align: center
      font-size: 10px
      color: rgb(147, 153, 159)
    .icon-add_circle
      display: inline-block
      padding: 6px
      line-height: 24px
      font-size: 24px
      color $green
</style>
